package com.orange.score.activity.more;

import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.res.Resources;
import android.os.Bundle;
import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
import android.text.Editable;
import android.text.method.DigitsKeyListener;
import android.util.Log;
import android.view.Window;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast;
import com.orange.score.activity.common.CommonFootballActivity;
import java.util.List;

public class ScorePromptActivity extends PreferenceActivity
  implements Preference.OnPreferenceClickListener, Preference.OnPreferenceChangeListener
{
  private static final String TAG = "ScorePromptActivity";
  private CheckBoxPreference autolockPref;
  private CheckBoxPreference pushPref;
  private EditTextPreference refleshTimePref;
  private SharedPreferences sharedPreferences;
  private CheckBoxPreference soundPref;
  private CheckBoxPreference vibratePref;

  private void initPref()
  {
    this.sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this);
    String str = this.sharedPreferences.getString("refleshTime_editTextPref", "20");
    Log.i("refleshTime_editTextPref value=", str);
    this.refleshTimePref.setSummary(str + "秒");
  }

  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    addPreferencesFromResource(2131034112);
    getWindow().addFlags(128);
    getListView().setBackgroundColor(getResources().getColor(2131230739));
    getListView().setDividerHeight(0);
    this.refleshTimePref = ((EditTextPreference)findPreference("refleshTime_editTextPref"));
    this.soundPref = ((CheckBoxPreference)findPreference("sound_checkboxPref"));
    this.vibratePref = ((CheckBoxPreference)findPreference("vibrate_checkboxPref"));
    this.pushPref = ((CheckBoxPreference)findPreference("push_checkboxPref"));
    this.autolockPref = ((CheckBoxPreference)findPreference("autoLock_checkboxPref"));
    EditText localEditText = this.refleshTimePref.getEditText();
    localEditText.setKeyListener(DigitsKeyListener.getInstance(false, true));
    localEditText.setHint("比分实时刷新时间间隔，最小10秒");
    this.refleshTimePref.setOnPreferenceChangeListener(this);
    this.refleshTimePref.setOnPreferenceClickListener(this);
    this.soundPref.setOnPreferenceChangeListener(this);
    this.soundPref.setOnPreferenceClickListener(this);
    this.vibratePref.setOnPreferenceChangeListener(this);
    this.vibratePref.setOnPreferenceClickListener(this);
    this.pushPref.setOnPreferenceChangeListener(this);
    this.pushPref.setOnPreferenceClickListener(this);
    this.autolockPref.setOnPreferenceChangeListener(this);
    this.autolockPref.setOnPreferenceClickListener(this);
    initPref();
    CommonFootballActivity.activityList.add(this);
  }

  public boolean onPreferenceChange(Preference paramPreference, Object paramObject)
  {
    int i;
    Log.i("ScorePromptActivity", "onPreferenceChange----->" + String.valueOf(paramPreference.getKey()));
    if (paramPreference == this.refleshTimePref)
    {
      String str1 = this.sharedPreferences.getString("refleshTime_editTextPref", "20");
      String str2 = this.refleshTimePref.getEditText().getText().toString().trim();
      if (str2.equals(""))
        str2 = "20";
      int j = Integer.valueOf(str2).intValue();
      if (j >= 3600)
      {
        str2 = "3600";
        Toast.makeText(getApplicationContext(), "刷新时间间隔最大不超过3600秒", 0).show();
      }
      if (j < 10)
      {
        str2 = "10";
        Toast.makeText(getApplicationContext(), "刷新时间间隔最少为10秒", 0).show();
      }
      this.sharedPreferences.edit().putString("refleshTime_editTextPref", str2).commit();
      Log.i("ScorePromptActivity", "oldValue=" + str1 + ",newValue=" + str2);
      this.refleshTimePref.setSummary(str2 + "秒");
      i = 0;
    }
    while (true)
    {
      return i;
      i = 1;
    }
  }

  public boolean onPreferenceClick(Preference paramPreference)
  {
    Log.i("ScorePromptActivity", "onPreferenceClick----->" + String.valueOf(paramPreference.getKey()));
    if (paramPreference == this.refleshTimePref)
    {
      String str = this.sharedPreferences.getString("refleshTime_editTextPref", "20");
      this.refleshTimePref.getEditText().setText(str);
    }
    return true;
  }
}